from django.conf.urls import url
from django.contrib.auth.decorators import login_required

from . import views

# users/urls
# namespace=users

urlpatterns = [
    url(r'^register/$', views.Register.as_view(), name='register'),
    url(r'^login/$', views.Login.as_view(), name='login'),
    # 用户中心
    # url(r'^usercenter/$', login_required(views.UserCenter.as_view()), name='user_center'),
    url(r'^usercenter/$', views.UserCenter.as_view(),name='user_center'),
    url(r'^emails/$', views.EmailActive.as_view(), name='active_email'),
    url(r'^alterpassword/$', views.AlterPassword.as_view(), name='alter_password'),
    url(r'^address/$', views.UserAddress.as_view(), name='user_address'),
    url(r'^user/order/$', views.OrderManager.as_view(), name='order'),
    url(r'^address/(?P<id>\d+)/default/$', views.UserAddress.as_view()),   # 设置默认收货地址
    url(r'^address/add/$', views.AddressManager.as_view()),     # 添加收货地址
    url(r'^address/(?P<id>\d+)/$', views.AddressManager.as_view(),),  # 修改、删除收货地址(标题)


    url(r'^logout/$', views.Logout.as_view(), name='logout'),
    url(r'^usernames/(?P<name>[a-zA-Z0-9_-]{5,20})/count/$', views.username_count),
    url(r'^mobile/(?P<mobile>1[3-9]\d{9})/count/$', views.mobile_count),
    # 用户商品浏览记录
    url(r'^browse_histories/$', views.UserBrowseHistory.as_view()),
]
